package java_thinking.unit_10._10_10;

/**
 * @Description : 明确的继承某个内部类
 * @author: cww
 * @DateTime: 2019-03-16 15:53
 */

public class Egg2 {
    protected class Yolk{
        public Yolk(){
            System.out.println("Egg2.Yolk()");
        }
        public void f(){
            System.out.println("Egg2.f()");
        }
    }
    //初始化构造函数钱先初始化对象的域

    private int i = 3;
    private Yolk y = new Yolk();
    public Egg2(){
        System.out.println("New Egg2()");
    }
    public void insertYolk(Yolk yy){
        y = yy;
    }
    public void g(){
        y.f();
    }
}
class BigEgg2 extends Egg2{
    /**
     * 明确继承Egg2.Yolk，初始化时Egg2.Yolk()会先初始化再到当前这个Yolk
     */
    public class Yolk extends Egg2.Yolk{
        public Yolk(){
            System.out.println("BigEgg2.Yolk()");
        }
        @Override
        public void f(){
            System.out.println("BigEgg2.Yolk.f()");
        }
    }
    public BigEgg2(){
        insertYolk(new Yolk());
    }

    public static void main(String[] args) {
        Egg2 e2 = new BigEgg2();
        e2.g();
    }
}
